home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / emac16as.arc / EXECUTE.ASM < prev    next >
Assembly Source File  |  1990-04-01  |  4KB  |  200 lines

  1. ;History:14,1
  2. ;Sun Mar 26 20:54:16 1989 remove reference to textseg.
  3. ;03-27-88 14:27:20 remove execute_filter code.
  4. ;03-13-88 12:26:39 remove the execute filter stuff.
  5. stderr        equ    1
  6.  
  7.     .xlist
  8.     include    memory.def
  9.  
  10. data    segment    byte public
  11.  
  12.     extrn    phd_seg: word
  13.  
  14. fcb_struc    struc
  15. fcb_drive    db    0
  16. fcb_fname    db    '        '
  17. fcb_ext        db    '   '
  18. fcb_curblk    dw    0
  19. fcb_recsz    dw    0
  20. fcb_filsz    dw    0,0
  21. fcb_date    dw    0
  22. fcb_time    dw    0
  23. fcb_res        dd    ?,?
  24. fcb_currec    db    0
  25. fcb_ranrec    dw    0,0
  26. fcb_struc    ends
  27.  
  28. segofs    struc
  29. offs    dw    ?
  30. segm    dw    ?
  31. segofs    ends
  32.  
  33.  
  34. data    ends
  35.  
  36.  
  37. code    segment    byte public
  38. ;all the routines in this segment are entered with ds=data, es=data
  39.     assume    cs:code, ds:data, es:data, ss:data
  40.  
  41. ;the following externs are in 'buffers'
  42.     extrn    compact_buffers: near
  43.     extrn    uncompact_buffers: near
  44.  
  45. ;the following externs are in 'memory'
  46.     extrn    read_mark: near
  47.     extrn    del_to_mark: near
  48.     extrn    insert_string$: near
  49.  
  50. ;the following externs are in 'redisplay'
  51.     extrn    redisplay: near
  52.     extrn    paint_screen: near
  53.  
  54.     extrn    init_entry: near
  55.     extrn    uninit_exit: near
  56.  
  57.     extrn    abort_fatal: near    ;fatal error handler
  58.  
  59. our_sp    dw    ?
  60. our_ss    dw    ?
  61.  
  62. parameters    dw    0
  63.         dw    80h, ?
  64.         dw    5ch, ?
  65.         dw    6ch, ?
  66.  
  67. copy_to_dioa:
  68. ;enter with si, cx->command.
  69. ;exit with cs:phd_dioa set to the string.
  70.     push    es
  71.     mov    es,phd_seg        ;copy the command to phd_dioa+1
  72.     mov    di,80h+1
  73.   if 0
  74.     mov    ax,3700h        ;get the switch char.
  75.     int    21h
  76.     mov    al,dl
  77.     stosb
  78.     mov    al,'C'            ;store -C or /C.
  79.     stosb
  80.   endif
  81.     rep    movsb
  82.     mov    al,CR            ;store the terminating CR.
  83.     stosb
  84.     sub    di,80h+1+1        ;don't count the CR.
  85.     mov    ax,di
  86.     mov    es:[80h],al        ;store the count.
  87.     pop    es            ;restore es.
  88.     ret
  89.  
  90.  
  91.     public    execute_program
  92. execute_program:
  93. ;enter with si, cx->path of filter to execute, di ->null terminated filename.
  94. ;exit with ax=return result.
  95.     push    di
  96.     call    copy_to_dioa
  97.     pop    di
  98.     call    actually_execute
  99.     ret
  100.  
  101.  
  102. actually_execute:
  103. ;enter with di -> filename, cs:phd_dioa = arguments.
  104.     push    di
  105.     call    uninit_exit
  106.     pop    di
  107.  
  108.     push    ds
  109.     push    es
  110.  
  111.     push    di
  112.     call    compact_buffers        ;make room for the program.
  113.     pop    di
  114.  
  115.     mov    dx,phd_seg        ;subtract off the allocated segment.
  116.     sub    bx,dx
  117.     mov    es,dx            ;get es=allocated segment.
  118.     assume    es:nothing
  119.  
  120.     mov    ah,4ah            ;reduce ourself in size.
  121.     int    21h
  122.  
  123.     mov    our_sp,sp        ;remember our stack.
  124.     mov    our_ss,ss
  125.  
  126.     mov    ds,phd_seg        ;move ds first because we need ds.
  127.     assume    ds:nothing
  128.     mov    es,phd_seg
  129.     assume    es:nothing
  130.  
  131.     mov    dx,di            ;set up to execute the program.
  132.  
  133.     mov    ax,2901h        ;parse fcb1.
  134.     mov    si,81h            ;->phd_sdioa.
  135.     mov    di,5ch            ;->phd_fcb1
  136.     int    21h
  137.  
  138.     mov    ax,2901h        ;parse fcb2.
  139.     mov    di,6ch            ;->phd_fcb2.
  140.     int    21h
  141.  
  142.     push    ss            ;ss:dx -> filename to execute.
  143.     pop    ds
  144.     assume    ds:data
  145.     push    cs
  146.     pop    es
  147.     assume    es:code
  148.     mov    bx,offset parameters
  149.     mov    ax,phd_seg
  150.     mov    es:[bx]+4,ax        ;use original phd parameters.
  151.     mov    es:[bx]+8,ax
  152.     mov    es:[bx]+12,ax
  153.     mov    ax,4b00h
  154.     int    21h
  155.     jc    actually_execute_1
  156.     xor    ax,ax            ;make sure ax is zero if no errors.
  157. actually_execute_1:
  158.  
  159.     cli                ;get our stack back.
  160.     mov    ss,cs:our_ss
  161.     mov    sp,cs:our_sp
  162.     sti
  163.  
  164.     push    ax
  165.  
  166.     mov    bx,0ffffh        ;now grab all of memory again.
  167.     mov    es,phd_seg
  168.     mov    ah,4ah            ;see how much is available.
  169.     int    21h
  170.     mov    ah,4ah            ;grab all of it.
  171.     int    21h
  172.  
  173.     push    cs            ;reset the fatal error address.
  174.     pop    ds
  175.     mov    dx,offset abort_fatal
  176.     mov    ax,2524h
  177.     int    21h
  178.  
  179.     mov    ax,33h*256+1        ;turn break checking back off.
  180.     mov    dl,0            ;  in case someone turned it on.
  181.     int    21h
  182.  
  183.     pop    ax
  184.  
  185.     pop    es
  186.     pop    ds
  187.     assume    ds:data, es:data
  188.  
  189.     push    ax
  190.     call    uncompact_buffers        ;make room for the text again.
  191.     call    init_entry
  192.     call    paint_screen
  193.     pop    ax
  194.     ret
  195.  
  196.  
  197. code    ends
  198.  
  199.     end
  200.